package o;

import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.a;

public final class agf implements agc {
    private int ˊ;
    private long ˋ;
    private boolean ˎ;
    private final anc ˏ = new anc(10);
    private aef ॱ;
    private int ᐝ;

    public void ˏ() {
        this.ˎ = false;
    }

    public void ˏ(ady o_ady, a aVar) {
        aVar.ˊ();
        this.ॱ = o_ady.ˊ(aVar.ˏ(), 4);
        this.ॱ.ˎ(Format.ˏ(aVar.ˎ(), "application/id3", null, -1, null));
    }

    public void ˋ(long j, int i) {
        if ((i & 4) != 0) {
            this.ˎ = true;
            this.ˋ = j;
            this.ˊ = 0;
            this.ᐝ = 0;
        }
    }

    public void ˊ(anc o_anc) {
        if (this.ˎ) {
            int ˊ = o_anc.ˊ();
            if (this.ᐝ < 10) {
                int min = Math.min(ˊ, 10 - this.ᐝ);
                System.arraycopy(o_anc.ˏ, o_anc.ˋ(), this.ˏ.ˏ, this.ᐝ, min);
                if (min + this.ᐝ == 10) {
                    this.ˏ.ˋ(0);
                    if (73 == this.ˏ.ʽ() && 68 == this.ˏ.ʽ() && 51 == this.ˏ.ʽ()) {
                        this.ˏ.ˎ(3);
                        this.ˊ = this.ˏ.ʿ() + 10;
                    } else {
                        amz.ˏ("Id3Reader", "Discarding invalid ID3 tag");
                        this.ˎ = false;
                        return;
                    }
                }
            }
            ˊ = Math.min(ˊ, this.ˊ - this.ᐝ);
            this.ॱ.ˎ(o_anc, ˊ);
            this.ᐝ = ˊ + this.ᐝ;
        }
    }

    public void ˋ() {
        if (this.ˎ && this.ˊ != 0 && this.ᐝ == this.ˊ) {
            this.ॱ.ˋ(this.ˋ, 1, this.ˊ, 0, null);
            this.ˎ = false;
        }
    }
}
